<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
    .d1{
        width: auto;
        height: 300px;
        background-color: red;
        margin-top: 50px;
        position: relative;
    }
    .d2{
        width: 100px;
        height: 100px;
        background-color: blue;
        position: absolute;
        top: 10px;
        /* 针对浏览器边框 ，如果父类元素有position: relative 就变得针对父类边框改变*/
    }
        </style>
</head>
<body>
    <div class="d1">
        <div class="d2"></div>
    </div>
</body>
</html>